package org.example.server.app.goods.mapstruct;

import org.example.api.search.controller.response.GoodsDocSummeryResponse;
import org.example.frw.api.base.response.PageResponse;
import org.example.server.app.goods.response.PageAppResponse;
import org.example.server.app.goods.response.goods.Goods;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper(componentModel = "spring")
public interface GoodsAppConverter {
  /**
   * 转换实例
   */
  GoodsAppConverter INSTANCE = Mappers.getMapper(GoodsAppConverter.class);

  Goods toGoods(GoodsDocSummeryResponse response);

  List<Goods> toGoods(List<GoodsDocSummeryResponse> data);

  @Mapping(target = "data", source = "items")
  @Mapping(target = "perPage", source = "pageSize")
  @Mapping(target = "currentPage", source = "current")
  PageAppResponse<Goods> toPageAppResponse(PageResponse<Goods> goodsPageResponse);
}
